package com.codechuan.hallo_internal.utils;

import android.os.Handler;
import android.os.Looper;

public class JDBCRequestUtils {
    private static final Handler handler = new Handler(Looper.getMainLooper());

    public static <T> void request(JDBCOperator<T> jdbcOperator,UIOperator<T> uiOperator){
        new Thread(){
            @Override
            public void run() {
                T data = jdbcOperator.execute();
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        uiOperator.updateUI(data);
                    }
                });
            }
        }.start();

    }


    public interface JDBCOperator<T>{
        T execute();
    }

    public interface UIOperator<T>{
        void updateUI(T t);
    }
}
